package com.wfh.picture.api.imagesearch;

import com.wfh.picture.api.imagesearch.model.ImageSearchResult;
import com.wfh.picture.api.imagesearch.sub.GetImageFirstUrlApi;
import com.wfh.picture.api.imagesearch.sub.GetImageListApi;
import com.wfh.picture.api.imagesearch.sub.GetImagePageUrlApi;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * @Author FengHuan Wang
 * @Date 2025/5/14 9:49
 * @Version 1.0
 */
@Slf4j
public class ImageSearchApiFacade {

    /**
     * 搜索图片
     * @param imageUrl
     * @return
     */
    public static List<ImageSearchResult> searchImage(String imageUrl) {
        // 获取图片页面URL
        String imagePageUrl = GetImagePageUrlApi.getImagePageUrl(imageUrl);
        // 获取图片第一张URL
        String imageFirstUrl = GetImageFirstUrlApi.getImageFirstUrl(imagePageUrl);
        // 获取图片列表
        List<ImageSearchResult> imageList = GetImageListApi.getImageList(imageFirstUrl);
        // 返回图片列表
        return imageList;
    }
}
